import styles from './style.less';
import { connect, history } from 'umi';
import DevDetail from './DevDetail';
import DevPage from './DevPage'




const ProjectDev = (props) => {
    const {
        projectId,
        dispatch,
        routeParam,
        queryInitParams,
        projectPermission,
    } = props;

    if (routeParam.tab !== 'dev') {
        return <></>;
    }

    if (routeParam.itemId) {
        return <DevDetail projectId={projectId} projectPermission={projectPermission} devId={routeParam.itemId}  routeTabKey={routeParam.itemTab} />
    }
    const onQueryParamChange = (params) => {
        dispatch({
            type: 'queryParams/saveQueryParams',
            payload: {
                name: "devPage",
                params: params
            }
        });
    }

    return <DevPage onQueryParamChange={onQueryParamChange} projectId={projectId} projectPermission={projectPermission} queryInitParams={queryInitParams}></DevPage>

}


export default connect(({ queryParams}) => ({
    queryInitParams: queryParams.devPage,
}))(ProjectDev);